<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>车辆信息输入</title>
    <script>
        function submitForm() {
            const vehicleId = document.getElementById('vehicle_id').value;
            const speed = document.getElementById('speed').value;

            fetch('/submit', {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/x-www-form-urlencoded',
                },
                body: `vehicle_id=${vehicleId}&speed=${speed}`
            })
            .then(response => response.json())
            .then(data => {
                alert(`车辆ID: ${data.vehicle_id}, 速度km/h: ${data.speed}`);
            })
            .catch(error => console.error('Error:', error));
        }
    </script>
</head>
<body>
    <h1>输入车辆速度信息</h1>
    <form onsubmit="event.preventDefault(); submitForm();">
        <label for="vehicle_id">车辆 ID:</label>
        <input type="text" id="vehicle_id" name="vehicle_id" required><br><br>

        <label for="speed">速度km/h:</label>
        <input type="number" id="speed" name="speed" required><br><br>

        <button type="submit">确认</button>
    </form>
</body>
</html>
